feat: strict types - #2792
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds ChangesStrict type definition support
Estimated code review effort: 3 (Moderate) | ~30 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/orm/src/client/zod/factory.ts`:
- Around line 465-467: Update the strictness selection in the schema factory
around isStrict to use typeDef.strict === true instead of scanning
typeDef.attributes for @@strict. Preserve the existing z.strictObject and
z.looseObject selection so runtime validation matches the shared TypeDefDef
strictness contract.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6bdf47c3-47d3-460c-8073-cbee101456f1
📒 Files selected for processing (12)
packages/cli/test/ts-schema-gen.test.tspackages/language/res/stdlib.zmodelpackages/language/src/validators/attribute-application-validator.tspackages/language/test/attribute-application.test.tspackages/orm/src/client/crud-types.tspackages/orm/src/client/zod/factory.tspackages/schema/src/schema.tspackages/sdk/src/ts-schema-generator.tstests/e2e/orm/client-api/procedures.test.tstests/e2e/orm/client-api/typed-json-fields.test.tstests/e2e/orm/schemas/procedures/schema.tstests/e2e/orm/schemas/procedures/schema.zmodel
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/clients/tanstack-query/test/schemas/basic/schema.zmodel`:
- Around line 38-41: Make Profile.bio optional by changing its ZModel
declaration to use the optional string type in
packages/clients/tanstack-query/test/schemas/basic/schema.zmodel:38-41. Then run
zenstack generate to regenerate
packages/clients/tanstack-query/test/schemas/basic/schema-lite.ts:174-188,
ensuring Profile.fields.bio.optional is true.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ac00b7a9-3be4-49b9-91af-1461a683f680
📒 Files selected for processing (10)
packages/clients/fetch-client/test/fetch-client.test.tspackages/clients/fetch-client/test/schemas/basic/schema-lite.tspackages/clients/fetch-client/test/schemas/basic/schema.zmodelpackages/clients/fetch-client/test/schemas/no-procs/schema.tspackages/clients/fetch-client/test/typing.test-d.tspackages/clients/tanstack-query/test/react/react-typing.test-d.tspackages/clients/tanstack-query/test/schemas/basic/schema-lite.tspackages/clients/tanstack-query/test/schemas/basic/schema.zmodelpackages/clients/tanstack-query/test/svelte/svelte-typing-test.tspackages/clients/tanstack-query/test/vue/vue-typing-test.ts
Adds support for specifying custom type definitions should reject unknown fields via a new
@@strictattribute. This is reflected in both intellisense and runtime input validation.Sample Usage
Why not
@json(strict: true)? A type-level@@strictattribute is simpler to determine strictness, and also works with custom procedures.Summary by CodeRabbit
Summary by CodeRabbit
New Features
@@strictattribute for type definitions.updateProfileoperation to the example API.Bug Fixes
@@stricton models or enums now reports a validation error.